//
//  LawDetailViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/8.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "LawDetailViewController.h"

#define getLawsAndRegulationsInfo @"getLawsAndRegulationsInfo"

@interface LawDetailViewController ()
@property (nonatomic,strong) UIScrollView *backScrollView;
@property (nonatomic,strong) UILabel *msgLabel;
@end

@implementation LawDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setLeftBackNavigation];
    [self setNavigationTitle:[_navaTitle stringByAppendingString:@"制度"]];
    [self getLawsAndRegulationsInfoRequest];
    // Do any additional setup after loading the view.
}

- (void)creatViewWtihMessage:(NSString *)message{
    self.backScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT-64)];
    self.backScrollView.showsVerticalScrollIndicator=NO;
    self.backScrollView.showsHorizontalScrollIndicator=NO;
    self.backScrollView.bounces=NO;
    [self.view addSubview:self.backScrollView];
    
    CGFloat msgHeight=[LZXHelper textHeightFromTextString:message width:_backScrollView.width-16 fontSize:15]+5;
    self.msgLabel=[MyControl creatLabelWithFrame:CGRectMake(8, 8,_backScrollView.width-16 ,msgHeight ) text:message];
    //self.msgLabel.backgroundColor=[UIColor redColor];
    self.msgLabel.numberOfLines=0;
    self.msgLabel.font=FONT_15;
    [self.backScrollView addSubview:self.msgLabel];
    
    self.backScrollView.contentSize=CGSizeMake(0, msgHeight+16);
}


#pragma mark -获取倒计时间请求

- (void)getLawsAndRegulationsInfoRequest{
    
    NSDictionary *dict=@{
                         @"businessCode":_businessCode?_businessCode:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getLawsAndRegulationsInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *_model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([_model.code isEqualToString:@"200"]) {
            NSDictionary *dict=responseObject[@"retContent"];
            [self creatViewWtihMessage:dict[@"content"]];
        }else if([_model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:_model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
